#!/usr/bin/env python
#! -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
from django.db import models

# Create your models here.


class head_img(models.Model):
    logo = models.ImageField(u'网站LOGO', upload_to='index_head_img', blank=True)
    logo_url = models.URLField(u'LOGO跳转地址', blank=True)
    logo_text = models.CharField(u'公司名称', max_length=20)
    tel = models.ImageField(u'电话图标', upload_to='index_head_img', blank=True)
    tel_text = models.CharField(u'电话号码', max_length=20)

    publish_date = models.DateField(auto_now_add=True, blank=True)
    latest_date = models.DateField(auto_now=True, blank=True)

    def __unicode__(self):  # 在Python3中用 __str__ 代替 __unicode__
        return '头部信息'

    class Meta:
        verbose_name = '头部信息'
        verbose_name_plural = '头部信息'
        ordering = ['publish_date']


class navigation(models.Model):
    title = models.CharField(u"标题", max_length=10)
    url = models.URLField("标题链接地址", blank=True)
    row_number = models.IntegerField("标题行号", default=0, blank=True)

    publish_date = models.DateField(auto_now_add=True, blank=True)
    latest_date = models.DateField(auto_now=True, blank=True)

    def __unicode__(self):  # 在Python3中用 __str__ 代替 __unicode__
        return self.title

    class Meta:
        verbose_name = '导航栏'
        verbose_name_plural = '导航栏'
        ordering = ['row_number']


class banner(models.Model):
    title = models.CharField(u"名称", max_length=32)
    banner = models.ImageField(u'大图', upload_to='index_head_img', blank=True)
    banner_url = models.URLField(u'大图跳转地址', blank=True)
    key_id = models.IntegerField(u'显示序号', blank=False, default=0)

    publish_date = models.DateField(auto_now_add=True, blank=True)
    latest_date = models.DateField(auto_now=True, blank=True)

    def __unicode__(self):  # 在Python3中用 __str__ 代替 __unicode__
        return self.title

    class Meta:
        verbose_name = '首页轮播图'
        verbose_name_plural = '首页轮播图'
        ordering = ['key_id']


class common_admin(admin.ModelAdmin):
    class Media:
        js = (
            '/media/js/jquery-1.8.3.min.js',
            '/media/js/jquery.form.js',
            # '/media/js/django_ajax.js',
            '/media/js/tinymce/tinymce.min.js',
            '/media/js/textareas.js',
        )
